namespace EyeOpen.DddOrm.Domain
{
	using System.Collections.Generic;

	using System.Linq;

	using EyeOpen.DddOrm.Domain.Factories;

	using EyeOpen.Domain;

	public class Content
		: Aggregate
	{
		private readonly ICollection<ContentCategory> contentCategoryList;

		protected internal Content()
		{
			contentCategoryList = new List<ContentCategory>();
		}

		public virtual string Title { get; set; }

		public virtual string Description { get; set; }

		public virtual IEnumerable<Category> CategoryList
		{
			get
			{
				return contentCategoryList.Select(x => x.Category);
			}
		}

		protected internal virtual void AddCategoryList(IEnumerable<Category> categoryList)
		{
			Ensure
				.That(categoryList, "categoryList")
				.AllNotNull();

			foreach (var category in categoryList)
			{
				contentCategoryList.Add(ContentCategoryFactory.Create(this, category));
			}
		}
	}
}